<?php
namespace Assist\Controller;

class DetailController extends AssistController {
    /**
     * 获取系统通知列表
     *
     */
    public function index(){
        $category = $this->category();
         
        $Document = D('Document');
        
        $list = $Document->page($p, $category['list_row'])->lists($category['id'],'`level` DESC,`id` DESC');
        if(false === $list){
            $this->error('获取列表数据失败！');
        }
        
        $doclist = array();
        foreach($list as $item){
            $doclist[] = $Document->detail($item['id']);
        }
        
        $this->assign('info', $doclist);
        $this->display();
    }

    protected function category(){
        $category = D('Category')->info('detail');
        if($category && 1 == $category['status']){
            switch ($category['display']) {
                case 0:
                    $this->error('该分类禁止显示！');
                    break;
                default:
                    break;
            }
        } else {
            $this->error('分类不存在或被禁用！');
        }
        return $category;
    }
}